#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

int main()
{
    pid_t id = fork();
    if (id < 0)
    {
        // 创建失败
        perror("fork");
        return 1;
    }
    else if (id == 0)
    {
        // child
        while (1)
        {
            printf("I am child, pid : %d\n", getpid());
            sleep(1);
        }
        
    }
    else
    {
        // father
        printf("I am father, pid : %d\n", getpid());
        sleep(10);
        exit(0);
    }

    return 0;
}